# --*-- coding: utf-8 -*-

import numpy as np
import cv2
import sys
import math

if __name__ == "__main__":
    if len(sys.argv) > 1:
        image = cv2.imread(sys.argv[1], cv2.IMREAD_GRAYSCALE)
    else:
        print("Usage: python xxx image")
        exit
    print("usage image ", sys.argv[1])
    
    h, w = image.shape[:2]
    A1 = np.array([[0.5,0,0], [0,0.5,0]], np.float32)
    d1 = cv2.warpAffine(image, A1, (w, h), borderValue=125)

    A2 = np.array([[0.5, 0, w/4], [0, 0.5, h/4]], np.float32)
    d2 = cv2.warpAffine(image, A2, (w, h), borderValue=125)

    A3 = cv2.getRotationMatrix2D((w/2.0, h/2.0), 30, 1)
    d3 = cv2.warpAffine(image, A3, (w, h), borderValue=125)

    ## function to rotate instead rotation with matrix
    # d4 = cv2.rotate(image, cv2.ROTATE_90_CLOCKWISE)
    d5 = cv2.rotate(image, cv2.ROTATE_180)
    d6 = cv2.rotate(image, cv2.ROTATE_90_COUNTERCLOCKWISE)

    cv2.imshow("image", image)
    cv2.imshow("d1", d1)
    cv2.imshow("d2", d2)
    cv2.imshow("d3", d3)
    cv2.imshow("d5", d5)
    cv2.imshow("d6", d6)
    cv2.waitKey(0)
    cv2.destroyAllWindows()